
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>上传</title>
</head>
<body>
<form method="post">
    <h3>
        当前客户端 {{ user }}，请上传分数：<input type="text" id="score" name="score" placeholder="可输入范围：1~10000000。"> 分。
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input name="" type="button" value="提交" onclick="return sub()"/><div id="score_err" style="color: red;"></div>
        <div id="score_err" style="color: red;"></div>
    </h3>
</form>
&nbsp;&nbsp;
<a href="{% url 'app01:show' %}"><input name="" type="button" value="查询"/></a>
&nbsp;&nbsp;
<a href="/logout/"><input name="" type="button" value="退出"/></a>

<script language="JavaScript" src="/static/js/jquery-1.12.3.min.js"></script>
<script type="text/javascript">
    function sub() {
        var score = $('#score').val();
        var flag = true;
        if (score < 1 || score > 10000000) {
            $('#score_err').text('分数不符合规范！');
            flag = false;
        }
        if (flag) {
            $.ajax({
                url: '/upload/',
                data: {'score': score},
                type: 'POST',
                success: function (result) {
                    alert(result.status)
                }
            })
        }
        return flag;
    }
</script>

</body>

</html>>